//TIP 要<b>运行</b>代码，请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
    public static void main(String[] args) {
        //TIP 当文本光标位于高亮显示的文本处时按 <shortcut actionId="ShowIntentionActions"/>
        // 查看 IntelliJ IDEA 建议如何修正。
        System.out.println("Hello and welcome!");

        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();

        originator.setState("状态1");
        originator.setState("状态2");
        caretaker.add(originator.saveStateToMemento());

        originator.setState("状态3");
        caretaker.add(originator.saveStateToMemento());

        originator.setState("状态4");

        System.out.println("当前状态: " + originator.getState());
        originator.getStateFromMemento(caretaker.get(0));
        System.out.println("第一次保存的状态: " + originator.getState());
        originator.getStateFromMemento(caretaker.get(1));
        System.out.println("第二次保存的状态: " + originator.getState());

    }
}